
using System;
using System.Collections.Generic;

namespace Gamadus.Engine
{
	public class ObjectSuper : Resource
	{		
		private double m_x,m_y, m_hspeed,m_vspeed,m_depth,m_visible, m_persistent;

		InstanceVarList variable;
		
		public InstanceVarList Variable
		{
			get
			{
				return variable;
			}
		}
		
		public GmlVar persistent
		{
			get
			{
				return m_persistent;
			}
			set
			{
				m_persistent = value.GetReal();
			}
		}
		
		public GmlVar depth
		{
			get
			{
				return m_depth;
			}
			set
			{
				m_depth = value.GetReal();
			}
		}
		
		public GmlVar visible
		{
			get
			{
				return m_visible;
			}
			set
			{
				m_visible = value.GetReal();
			}
		}
		
		public GmlVar x
		{
			get
			{
				return m_x;
			}
			set
			{
				m_x = value.GetReal();
			}
		}
		
		public GmlVar y
		{
			get
			{
				return m_y;
			}
			set
			{
				m_y = value.GetReal();
			}
		}
		
		public GmlVar hspeed
		{
			get
			{
				return m_hspeed;
			}
			set
			{
				m_hspeed = value.GetReal();
			}
		}
		
		public GmlVar vspeed
		{
			get
			{
				return m_vspeed;
			}
			set
			{
				m_vspeed = value.GetReal();
			}
		}
		
		//protected Sprite sprite;
		Room room;
		protected ObjectSuper(int id, double x, double y, Room room) : base(id)
		{
			//gamavars_Sprite = null;
			m_x=x;
			m_y=y;
			m_hspeed=0;
			m_vspeed=0;
			//sprite_index = new GamadusSprite("hero.png",24,32,4);
			//if(GamadusMain.RMctrl.rooms[rm_nr]==null)
			this.room = room;
			
			variable = new InstanceVarList(this);
			
			room.AddInstance(this);
		}
		
		public void Create()
		{
			__EventCreate();
		}
		
		protected virtual void __EventCreate()
		{
			
		}
		
		public void Destroy()
		{
			__EventDestroy();
			room.RemoveInstance(this);
		}
		
		protected virtual void __EventDestroy()
		{
			
		}
		
		public void Step() //all things except drawing
		{
			
			//TODO: execute internal movement if wanted
			x+=hspeed;
			y+=vspeed;
			
			__EventStep();
		}
		
		protected virtual void __EventStep()
		{
			
		}
		
		public void Draw() //only drawing
		{
			__EventDraw();
		}
		
		protected virtual void __EventDraw()
		{
			//TODO: draw standard sprite
//			if(gamavars_Sprite!=null)
//			gamavars_Sprite.draw(gamavars_X,gamavars_Y);
		}
	}
}
